<template>
	<view class="interest">
		<view class="top">
			<view class="item">
				<view>{{$t('lixibao.deposit')}}</view>
				<view class="num"> <text>{{info.pzcpamount}}</text></view>
			</view>
			<view class="item">
				<view>{{$t('lixibao.revenue')}}</view>
				<view class="num"> <text>{{info.total_profit}}</text></view>
			</view>
		</view>
		<view class="deposit-btn"  @click="toWithdraw">
			<image src="../../../../static/lxb.png" class="icon"></image>
			<text>{{$t('lixibao.save')}}</text>
		</view>
		<view class="list-wrap" v-if="show">
			<view class="per-list" v-for="(item,index) in  info.datalist" :key="index">
				<view class="left">
					<text>{{item.amount}}({{item.profit_percent}})</text>
					<text>{{item.end_time}} {{$t('lixibao.expiration')}}</text>
					<text>{{item.start_time}}</text>
				</view>
				<view class="list-btn" @click="handleWithDraw(item.id)">{{$t('lixibao.withdraw')}}</view>
			</view>			
		</view>
		<view class="none" v-else>
			<image src="../../../../static/images/member/default.png" class="default"></image>
			<text class="none-txt">暂无记录</text>
			<text class="init-btn"  @click="toWithdraw">去存钱</text>
		</view>
	</view>
</template>

<script>
	import fetch from '@/common/fetch.js'
	export default{
		data(){
			return{
				show:true,
				info:{}
			}			
		},
		onLoad(){
			 uni.setNavigationBarTitle({
			            title:this.$t('lixibao.title')
			        });
		},
		onShow(){
			this.getInfo()
		},
		methods:{
			getInfo(){
				fetch.request('/index/Yulibao/index','','GET').then(res=>{
					let {data} = res
					this.info = data
				})
			},
			handleWithDraw(id){
				let that = this
				uni.showModal({
				    title: this.$t('lixibao.toastTitle'),
				    content: this.$t('lixibao.toastContent'),
					cancelText:this.$t('lixibao.cancel'),
					confirmText:this.$t('lixibao.confirm'),
				    success: function (res) {			
				        if (res.confirm) {
							let postdata = {
								id:id
							}
				            fetch.request('/index/Yulibao/preconfirm',postdata,'POST').then(data=>{
								fetch.toast(data.data)
								setTimeout(function(){
									that.getInfo()
								},1000)								
							})
				        }
				    }
				});
			},
			toWithdraw(){
				uni.navigateTo({
					url:'./withdraw'
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	page,.interest{
		width: 100%;
		min-height: 100%;
	}
	.top{
		display: flex;
		padding: 48rpx 20rpx;
		box-sizing: border-box;
		background: #F53D46;
		color: #fff;
		font-size: 12px;
		height: 210rpx;
		.item{
			flex: 1;			
			.num{
				margin-top: 8rpx;
				display: flex;
				align-items: flex-start;
				text{
					font-size: 24px;
					margin-top: -4rpx;
				}
			}
		}
	}
	.deposit-btn{
		height: 80rpx;
		width: 710rpx;
		border-radius: 20rpx;
		margin-left: 20rpx;
		line-height: 80rpx;
		text-align: center;
		font-size: 16px;
		background: #fff;
		margin-top: -50rpx;
		.icon{
			width: 60rpx;
			height: 52rpx;
			vertical-align: middle;
			margin-right: 20rpx;
		}
	}
	.list-wrap{
		width: 710rpx;
		margin-left: 20rpx;
		margin-top: 40rpx;
		.per-list{
			padding: 20rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.left{
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				text{
					font-size: 12px;
					color: #fabc08;
					&:nth-child(1){
						font-size: 16px;
						color: #ff7800;
					}
					&:nth-child(2){
						margin:10rpx 0;
					}
					&:nth-child(3){
						color: #aaa;
					}
				}
				
				
			}
			.list-btn{
				width: 120rpx;
				height: 64rpx;
				color: #fff;
				border-radius: 60rpx;
				text-align: center;
				line-height: 62rpx;
				background: #F53D46;
			}
		}
	}
	.none{
		width: 100%;
		display: flex;		
		flex-direction: column;
		align-items: center;
		justify-content: center;
		font-size: 14px;
		.default{
			width: 320rpx;
			height: 260rpx;
		}
		.none-txt{
			margin: 60rpx 0 40rpx 0;
			color: #999;
		}
		.init-btn{
			width: 280rpx;
			height: 92rpx;
			line-height: 92rpx;
			color: #fff;
			background: #F53D46;
			text-align: center;
			border-radius: 92rpx;
		}
	}
</style>
